package com.dwxt.mall.controller;

import com.alibaba.fastjson.JSONObject;
import com.dwxt.common.base.BaseResult;
import com.dwxt.common.util.OkHttpUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RequestMapping("/mall")
@RestController
public class MinAPPController {

    @RequestMapping("/getOpenId")
    public BaseResult getOpenId(String code) {
        String url = "https://api.weixin.qq.com/sns/jscode2session?appid=wx44613790d6c45749&secret" +
                "=31151b5a718cd05859dd4e29a5f8f301&js_code=" + code + "&grant_type=authorization_code";
        String s = OkHttpUtils.synGet(url, null);
        JSONObject result = JSONObject.parseObject(s);
        return BaseResult.ok(result);
    }
}
